package com.dhecp.project.finance.service.impl;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.dhecp.common.core.domain.AjaxResult;
import com.dhecp.common.utils.MessageUtils;
import com.dhecp.project.finance.domain.AccountCountForCompany;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhecp.core.constant.DataFiltering;
import com.dhecp.core.utils.PageUtils;
import com.dhecp.project.common.service.impl.BaseModuleServiceImpl;
import com.dhecp.project.finance.domain.AccountCountForUser;
import com.dhecp.project.finance.mapper.AccountCountForUserMapper;
import com.dhecp.project.finance.service.AccountCountForUserService;
import com.dhecp.project.system.service.SysDictionaryForFieldService;

/**
 * 用户实时资金 服务层
 * @author DH-Xxj
 * @version 2022年10月19日
 */
@Service
public class AccountCountForUserServiceImpl extends BaseModuleServiceImpl implements AccountCountForUserService {

	@Autowired
	private AccountCountForUserMapper businessMapper;
	
	@Autowired
	private SysDictionaryForFieldService dictionaryForFieldService;
	
	/**
	 * 查询
	 * @param params
	 * @return List - AccountCountForUser
	 * @throws Exception
	 * @author DH-Xxj
	 */
	@Override
    public List<AccountCountForUser> queryList(Map<String, Object> params) throws Exception {
        params.put(DataFiltering.TABLE_ALIAS, "t1");	//查询表别名
        params.put(DataFiltering.DATA_WHERE, dictionaryForFieldService.getWhereStr(params));	//常规查询条件SQL语句
        params.put(DataFiltering.DATA_SCODE, dictionaryForFieldService.getDataScode(params));	//数据权限查询条件SQL语句
        if (params.get("field") == null || params.get("field") == ""){
			String orderBy = "userId asc";
			PageUtils.startPageOrder(orderBy);
		}else{
			PageUtils.startPage();	
		}
        return businessMapper.selectAll(params);
    }


	/**
	 * 修改负债额度
	 *
	 * @param params
	 * @return
	 * @author DH-Xxj
	 */
	@Override
	public AjaxResult updateType(Map<String, Object> params) {
		AccountCountForUser item = JSON.parseObject(params.get("infoItem").toString(), AccountCountForUser.class);
		businessMapper.update(item);
		return AjaxResult.success(MessageUtils.message("module.success.issuccess"));
	}
}
